
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>样式 · introduce</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Gj">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-tomorrow.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../index.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="permission.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    引导
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="vscode.html">
            
                <a href="vscode.html">
            
                    
                    Vscode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="jsdoc.html">
            
                <a href="jsdoc.html">
            
                    
                    Jsdoc
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="webpack.html">
            
                <a href="webpack.html">
            
                    
                    Webpack
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="router.html">
            
                <a href="router.html">
            
                    
                    路由和侧边栏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="env.html">
            
                <a href="env.html">
            
                    
                    环境变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="cors.html">
            
                <a href="cors.html">
            
                    
                    跨域问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="router-lazyload.html">
            
                <a href="router-lazyload.html">
            
                    
                    路由懒加载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="icons.html">
            
                <a href="icons.html">
            
                    
                    图标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="i18n.html">
            
                <a href="i18n.html">
            
                    
                    国际化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="eslint.html">
            
                <a href="eslint.html">
            
                    
                    ESLint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="permission.html">
            
                <a href="permission.html">
            
                    
                    权限验证
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.13" data-path="style.html">
            
                <a href="style.html">
            
                    
                    样式
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >样式</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x6837;&#x5F0F;">&#x6837;&#x5F0F;</h1>
<h2 id="css-modules">CSS Modules</h2>
<p>&#x5728;&#x6837;&#x5F0F;&#x5F00;&#x53D1;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x6709;&#x4E24;&#x4E2A;&#x95EE;&#x9898;&#x6BD4;&#x8F83;&#x7A81;&#x51FA;&#xFF1A;</p>
<ul>
<li>&#x5168;&#x5C40;&#x6C61;&#x67D3; &#x2014;&#x2014; CSS &#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x9009;&#x62E9;&#x5668;&#x662F;&#x5168;&#x5C40;&#x751F;&#x6548;&#x7684;&#xFF0C;&#x4E0D;&#x540C;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x540C;&#x540D;&#x9009;&#x62E9;&#x5668;&#xFF0C;&#x6839;&#x636E; build &#x540E;&#x751F;&#x6210;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x5148;&#x540E;&#x987A;&#x5E8F;&#xFF0C;&#x540E;&#x9762;&#x7684;&#x6837;&#x5F0F;&#x4F1A;&#x5C06;&#x524D;&#x9762;&#x7684;&#x8986;&#x76D6;&#xFF1B;</li>
<li>&#x9009;&#x62E9;&#x5668;&#x590D;&#x6742; &#x2014;&#x2014; &#x4E3A;&#x4E86;&#x907F;&#x514D;&#x4E0A;&#x9762;&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x7F16;&#x5199;&#x6837;&#x5F0F;&#x7684;&#x65F6;&#x5019;&#x4E0D;&#x5F97;&#x4E0D;&#x5C0F;&#x5FC3;&#x7FFC;&#x7FFC;&#xFF0C;&#x7C7B;&#x540D;&#x91CC;&#x4F1A;&#x5E26;&#x4E0A;&#x9650;&#x5236;&#x8303;&#x56F4;&#x7684;&#x6807;&#x793A;&#xFF0C;&#x53D8;&#x5F97;&#x8D8A;&#x6765;&#x8D8A;&#x957F;&#xFF0C;&#x591A;&#x4EBA;&#x5F00;&#x53D1;&#x65F6;&#x8FD8;&#x5F88;&#x5BB9;&#x6613;&#x5BFC;&#x81F4;&#x547D;&#x540D;&#x98CE;&#x683C;&#x6DF7;&#x4E71;&#xFF0C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x4E0A;&#x4F7F;&#x7528;&#x7684;&#x9009;&#x62E9;&#x5668;&#x4E2A;&#x6570;&#x4E5F;&#x53EF;&#x80FD;&#x8D8A;&#x6765;&#x8D8A;&#x591A;&#xFF0C;&#x6700;&#x7EC8;&#x5BFC;&#x81F4;&#x96BE;&#x4EE5;&#x7EF4;&#x62A4;&#x3002;</li>
</ul>
<p>&#x597D;&#x5728; vue &#x4E3A;&#x6211;&#x4EEC;&#x63D0;&#x4F9B;&#x4E86; <a href="https://vue-loader.vuejs.org/guide/scoped-css.html#mixing-local-and-global-styles" target="_blank">scoped</a> &#x53EF;&#x4EE5;&#x5F88;&#x65B9;&#x4FBF;&#x7684;&#x89E3;&#x51B3;&#x4E0A;&#x8FF0;&#x95EE;&#x9898;&#x3002; &#x5B83;&#x987E;&#x540D;&#x601D;&#x4E49;&#x7ED9; css &#x52A0;&#x4E86;&#x4E00;&#x4E2A;&#x57DF;&#x7684;&#x6982;&#x5FF5;&#x3002;</p>
<pre class="language-"><code class="lang-css"><span class="token comment">/* &#x7F16;&#x8BD1;&#x524D; */</span>
<span class="token selector">.example</span> <span class="token punctuation">{</span>
  <span class="token property">color</span><span class="token punctuation">:</span> red<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token comment">/* &#x7F16;&#x8BD1;&#x540E; */</span>
<span class="token selector">.example[_v-f3f3eg9]</span> <span class="token punctuation">{</span>
  <span class="token property">color</span><span class="token punctuation">:</span> red<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x53EA;&#x8981;&#x52A0;&#x4E0A; <code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>style</span> <span class="token attr-name">scoped</span><span class="token punctuation">&gt;</span></span></code> &#x8FD9;&#x6837; css &#x5C31;&#x53EA;&#x4F1A;&#x4F5C;&#x7528;&#x5728;&#x5F53;&#x524D;&#x7EC4;&#x4EF6;&#x5185;&#x4E86;&#x3002;&#x8BE6;&#x7EC6;&#x6587;&#x6863;&#x89C1; <a href="https://vue-loader.vuejs.org/guide/scoped-css.html#mixing-local-and-global-styles" target="_blank">vue-loader</a></p>
<p>TIP</p>
<p>&#x4F7F;&#x7528; scoped &#x540E;&#xFF0C;&#x7236;&#x7EC4;&#x4EF6;&#x7684;&#x6837;&#x5F0F;&#x5C06;&#x4E0D;&#x4F1A;&#x6E17;&#x900F;&#x5230;&#x5B50;&#x7EC4;&#x4EF6;&#x4E2D;&#x3002;&#x4E0D;&#x8FC7;&#x4E00;&#x4E2A;&#x5B50;&#x7EC4;&#x4EF6;&#x7684;&#x6839;&#x8282;&#x70B9;&#x4F1A;&#x540C;&#x65F6;&#x53D7;&#x5176;&#x7236;&#x7EC4;&#x4EF6;&#x7684; scoped CSS &#x548C;&#x5B50;&#x7EC4;&#x4EF6;&#x7684; scoped CSS &#x7684;&#x5F71;&#x54CD;&#x3002;&#x8FD9;&#x6837;&#x8BBE;&#x8BA1;&#x662F;&#x4E3A;&#x4E86;&#x8BA9;&#x7236;&#x7EC4;&#x4EF6;&#x53EF;&#x4EE5;&#x4ECE;&#x5E03;&#x5C40;&#x7684;&#x89D2;&#x5EA6;&#x51FA;&#x53D1;&#xFF0C;&#x8C03;&#x6574;&#x5176;&#x5B50;&#x7EC4;&#x4EF6;&#x6839;&#x5143;&#x7D20;&#x7684;&#x6837;&#x5F0F;&#x3002;</p>
<h2 id="&#x76EE;&#x5F55;&#x7ED3;&#x6784;">&#x76EE;&#x5F55;&#x7ED3;&#x6784;</h2>
<p>vue-element-admin &#x6240;&#x6709;&#x5168;&#x5C40;&#x6837;&#x5F0F;&#x90FD;&#x5728; <code>@/styles</code> &#x4E0B;&#x8BBE;&#x7F6E;</p>
<pre class="language-"><code class="lang-bash">&#x251C;&#x2500;&#x2500; styles
&#x2502;   &#x251C;&#x2500;&#x2500; btn.scss                 <span class="token comment"># &#x6309;&#x94AE;&#x6837;&#x5F0F;</span>
&#x2502;   &#x251C;&#x2500;&#x2500; element-ui.scss          <span class="token comment"># &#x5168;&#x5C40;&#x81EA;&#x5B9A;&#x4E49; element-ui &#x6837;&#x5F0F;</span>
&#x2502;   &#x251C;&#x2500;&#x2500; index.scss               <span class="token comment"># &#x5168;&#x5C40;&#x901A;&#x7528;&#x6837;&#x5F0F;</span>
&#x2502;   &#x251C;&#x2500;&#x2500; mixin.scss               <span class="token comment"># &#x5168;&#x5C40;mixin</span>
&#x2502;   &#x251C;&#x2500;&#x2500; sidebar.scss             <span class="token comment"># sidebar css</span>
&#x2502;   &#x251C;&#x2500;&#x2500; transition.scss          <span class="token comment"># vue transition &#x52A8;&#x753B;</span>
&#x2502;   &#x2514;&#x2500;&#x2500; variables.scss           <span class="token comment"># &#x5168;&#x5C40;&#x53D8;&#x91CF;</span>
</code></pre>
<p>&#x5E38;&#x89C1;&#x7684;&#x5DE5;&#x4F5C;&#x6D41;&#x7A0B;&#x662F;&#xFF0C;&#x5168;&#x5C40;&#x6837;&#x5F0F;&#x90FD;&#x5199;&#x5728; <code>src/styles</code> &#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x6BCF;&#x4E2A;&#x9875;&#x9762;&#x81EA;&#x5DF1;&#x5BF9;&#x5E94;&#x7684;&#x6837;&#x5F0F;&#x90FD;&#x5199;&#x5728;&#x81EA;&#x5DF1;&#x7684; <code>.vue</code> &#x6587;&#x4EF6;&#x4E4B;&#x4E2D;</p>
<pre class="language-"><code class="lang-css">&lt;style&gt;
<span class="token comment">/* global styles */</span>
&lt;/style&gt;

&lt;style scoped&gt;
<span class="token comment">/* local styles */</span>
&lt;/style&gt;
</code></pre>
<h2 id="&#x81EA;&#x5B9A;&#x4E49;-element-ui-&#x6837;&#x5F0F;">&#x81EA;&#x5B9A;&#x4E49; element-ui &#x6837;&#x5F0F;</h2>
<p>&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x6765;&#x8BF4;&#x8BF4;&#x600E;&#x4E48;&#x8986;&#x76D6; element-ui &#x6837;&#x5F0F;&#x3002;&#x7531;&#x4E8E; element-ui &#x7684;&#x6837;&#x5F0F;&#x6211;&#x4EEC;&#x662F;&#x5728;&#x5168;&#x5C40;&#x5F15;&#x5165;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x4F60;&#x60F3;&#x5728;&#x67D0;&#x4E2A;&#x9875;&#x9762;&#x91CC;&#x9762;&#x8986;&#x76D6;&#x5B83;&#x7684;&#x6837;&#x5F0F;&#x5C31;&#x4E0D;&#x80FD;&#x52A0; scoped&#xFF0C;&#x4F46;&#x4F60;&#x53C8;&#x60F3;&#x53EA;&#x8986;&#x76D6;&#x8FD9;&#x4E2A;&#x9875;&#x9762;&#x7684; element &#x6837;&#x5F0F;&#xFF0C;&#x4F60;&#x5C31;&#x53EF;&#x5728;&#x5B83;&#x7684;&#x7236;&#x7EA7;&#x52A0;&#x4E00;&#x4E2A; class&#xFF0C;&#x7528;&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x6765;&#x89E3;&#x51B3;&#x95EE;&#x9898;&#x3002;</p>
<pre class="language-"><code class="lang-css"><span class="token selector">.article-page</span> <span class="token punctuation">{</span>
  <span class="token comment">/* &#x4F60;&#x7684;&#x547D;&#x540D;&#x7A7A;&#x95F4; */</span>
  <span class="token selector">.el-tag</span> <span class="token punctuation">{</span>
    <span class="token comment">/* element-ui &#x5143;&#x7D20;*/</span>
    <span class="token property">margin-right</span><span class="token punctuation">:</span> 0px<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p><strong>&#x5F53;&#x7136;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x6DF1;&#x5EA6;&#x4F5C;&#x7528;&#x9009;&#x62E9;&#x5668; &#x4E0B;&#x6587;&#x4F1A;&#x4ECB;&#x7ECD;</strong></p>
<h2 id="&#x7236;&#x7EC4;&#x4EF6;&#x6539;&#x53D8;&#x5B50;&#x7EC4;&#x4EF6;&#x6837;&#x5F0F;-&#x6DF1;&#x5EA6;&#x9009;&#x62E9;&#x5668;">&#x7236;&#x7EC4;&#x4EF6;&#x6539;&#x53D8;&#x5B50;&#x7EC4;&#x4EF6;&#x6837;&#x5F0F; &#x6DF1;&#x5EA6;&#x9009;&#x62E9;&#x5668;</h2>
<p>&#x5F53;&#x4F60;&#x5B50;&#x7EC4;&#x4EF6;&#x4F7F;&#x7528;&#x4E86; <code>scoped</code> &#x4F46;&#x5728;&#x7236;&#x7EC4;&#x4EF6;&#x53C8;&#x60F3;&#x4FEE;&#x6539;&#x5B50;&#x7EC4;&#x4EF6;&#x7684;&#x6837;&#x5F0F;&#x53EF;&#x4EE5; &#x901A;&#x8FC7; <code>&gt;&gt;&gt;</code> &#x6765;&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre class="language-"><code class="lang-css"><span class="token selector">&lt;style scoped&gt;
.a &gt;&gt;&gt; .b</span> <span class="token punctuation">{</span> <span class="token comment">/* ... */</span> <span class="token punctuation">}</span>
&lt;/style&gt;
</code></pre>
<p>&#x5C06;&#x4F1A;&#x7F16;&#x8BD1;&#x6210;</p>
<pre class="language-"><code class="lang-css"><span class="token selector">.a[data-v-f3f3eg9] .b</span> <span class="token punctuation">{</span>
  <span class="token comment">/* ... */</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5982;&#x679C;&#x4F60;&#x4F7F;&#x7528;&#x4E86;&#x4E00;&#x4E9B;&#x9884;&#x5904;&#x7406;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x5982; <code>sass</code> &#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; <code>/deep/</code> &#x6765;&#x4EE3;&#x66FF; <code>&gt;&gt;&gt;</code> &#x5B9E;&#x73B0;&#x60F3;&#x8981;&#x7684;&#x6548;&#x679C;&#x3002;</p>
<p>&#x6240;&#x4EE5;&#x4F60;&#x60F3;&#x8986;&#x76D6;&#x67D0;&#x4E2A;&#x7279;&#x5B9A;&#x9875;&#x9762; <code>element</code> &#x7684; button &#x7684;&#x6837;&#x5F0F;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x505A;&#xFF1A;</p>
<pre class="language-"><code class="lang-css"><span class="token selector">.xxx-container &gt;&gt;&gt; .el-button</span><span class="token punctuation">{</span>
  xxxx
<span class="token punctuation">}</span>
</code></pre>
<p><a href="https://vue-loader.vuejs.org/en/features/scoped-css.html" target="_blank">&#x5B98;&#x65B9;&#x6587;&#x6863;</a></p>
<h2 id="autoprefixer-&#x65B0;&#x7248;&#x672C;&#x5DF2;&#x65E0;&#x8BE5;&#x95EE;&#x9898;">Autoprefixer [&#x65B0;&#x7248;&#x672C;&#x5DF2;&#x65E0;&#x8BE5;&#x95EE;&#x9898;]</h2>
<p>vue-cli &#x6709;&#x4E00;&#x4E2A;&#x5C0F;&#x5751;&#xFF0C;&#x5B83;&#x9ED8;&#x8BA4; autoprefixer &#x53EA;&#x4F1A;&#x5BF9;&#x901A;&#x8FC7; vue-loader &#x5F15;&#x5165;&#x7684;&#x6837;&#x5F0F;&#x624D;&#x4F1A;&#x6709;&#x6709;&#x4F5C;&#x7528;&#xFF0C;&#x6362;&#x800C;&#x8A00;&#x4E4B;&#x4E5F;&#x5C31;&#x662F; .vue &#x6587;&#x4EF6;&#x91CC;&#x9762;&#x7684; css autoprefixer &#x624D;&#x4F1A;&#x6548;&#x679C;&#x3002;&#x76F8;&#x5173;&#x95EE;&#x9898; <a href="https://github.com/vuejs-templates/webpack/issues/544" target="_blank">issues/544</a> , <a href="https://github.com/vuejs-templates/webpack/issues/600" target="_blank">issues/600</a> &#x3002;&#x89E3;&#x51B3;&#x65B9;&#x6848;&#x4E5F;&#x5F88;&#x7B80;&#x5355;&#x7C97;&#x66B4;</p>
<pre class="language-"><code class="lang-html">//app.vue
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>style</span> <span class="token attr-name">lang</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>scss<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token style"><span class="token language-css">
  <span class="token atrule"><span class="token rule">@import</span> <span class="token string">&apos;./styles/index.scss&apos;</span><span class="token punctuation">;</span></span> // &#x5168;&#x5C40;&#x81EA;&#x5B9A;&#x4E49;&#x7684;css&#x6837;&#x5F0F;
</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>style</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<p>&#x4F60;&#x5728; .vue &#x6587;&#x4EF6;&#x4E2D;&#x5F15;&#x5165;&#x4F60;&#x8981;&#x7684;&#x6837;&#x5F0F;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#xFF0C;&#x6216;&#x8005;&#x4F60;&#x53EF;&#x4EE5;&#x6539;&#x53D8; vue-cli &#x7684;&#x6587;&#x4EF6;&#x5728; css-loader &#x524D;&#x9762;&#x5728;&#x52A0;&#x4E00;&#x4E2A; postcss-loader&#xFF0C;&#x5728;&#x524D;&#x9762;&#x7684; issue &#x5730;&#x5740;&#x4E2D;&#x5DF2;&#x7ECF;&#x7ED9;&#x51FA;&#x4E86;&#x89E3;&#x51B3;&#x65B9;&#x6848;&#x3002;&#x4E0D;&#x8FC7;&#x65B0;&#x7248;&#x672C;&#x5DF2;&#x7ECF;&#x9ED8;&#x8BA4;&#x89E3;&#x51B3;&#x5904;&#x7406;&#x4E86;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#x3002;</p>
<h2 id="postcss">Postcss</h2>
<p>&#x8FD9;&#x91CC;&#x518D;&#x6765;&#x8BF4;&#x4E00;&#x4E0B; postcss &#x7684;&#x914D;&#x7F6E;&#x95EE;&#x9898;&#xFF0C;&#x65B0;&#x7248;&#x7684; <a href="https://github.com/vuejs-templates/webpack" target="_blank">vue-cli webpack &#x6A21;&#x677F;</a> init &#x4E4B;&#x540E;&#x6839;&#x76EE;&#x5F55;&#x4E0B;&#x9ED8;&#x8BA4;&#x6709;&#x4E00;&#x4E2A;<code>postcss.config.js</code> &#x3002;vue-loader &#x7684; postcss &#x4F1A;&#x9ED8;&#x8BA4;&#x8BFB;&#x53D6;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x7684;&#x91CC;&#x7684;&#x914D;&#x7F6E;&#x9879;&#xFF0C;&#x6240;&#x4EE5;&#x5728;&#x8FD9;&#x91CC;&#x76F4;&#x63A5;&#x6539;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;&#x914D;&#x7F6E;&#x548C; <a href="https://github.com/postcss/postcss" target="_blank">postcss</a>&#x662F;&#x4E00;&#x6837;&#x7684;&#x3002;</p>
<pre class="language-"><code class="lang-javascript"><span class="token comment">// postcss.config.js</span>
module<span class="token punctuation">.</span>exports <span class="token operator">=</span> <span class="token punctuation">{</span>
  plugins<span class="token operator">:</span> <span class="token punctuation">{</span>
    autoprefixer<span class="token operator">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token comment">// package.json</span>
<span class="token string">&quot;browserslist&quot;</span><span class="token operator">:</span> <span class="token punctuation">[</span>
    <span class="token string">&quot;&gt; 1%&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;last 2 versions&quot;</span><span class="token punctuation">,</span>
    <span class="token string">&quot;not ie &lt;= 8&quot;</span>
  <span class="token punctuation">]</span>
</code></pre>
<p>&#x5982;&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x6240;&#x8FF0;&#x7684;&#xFF0C;autoprefixer &#x4F1A;&#x53BB;&#x8BFB;&#x53D6; package.json &#x4E0B; browserslist &#x7684;&#x914D;&#x7F6E;&#x53C2;&#x6570;</p>
<ul>
<li><code>&gt; 1%</code> &#x517C;&#x5BB9;&#x5168;&#x7403;&#x4F7F;&#x7528;&#x7387;&#x5927;&#x4E8E; 1%&#x7684;&#x6D4F;&#x89C8;&#x5668;</li>
<li><code>last 2 versions</code> &#x517C;&#x5BB9;&#x6BCF;&#x4E2A;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x6700;&#x8FD1;&#x4E24;&#x4E2A;&#x7248;&#x672C;</li>
<li><code>not ie &lt;= 8</code> &#x4E0D;&#x517C;&#x5BB9; ie8 &#x53CA;&#x4EE5;&#x4E0B;</li>
</ul>
<p>&#x5177;&#x4F53;&#x53EF;&#x89C1; <a href="https://github.com/ai/browserslist" target="_blank">browserslist</a></p>
<p><code>postcss</code>&#x4E5F;&#x8FD8;&#x6709;&#x5F88;&#x591A;&#x5F88;&#x591A;&#x5176;&#x5B83;&#x7684;&#x529F;&#x80FD;&#x5927;&#x5BB6;&#x53EF;&#x4EE5;<a href="https://www.postcss.parts/" target="_blank">&#x81EA;&#x884C;&#x53BB;&#x63A2;&#x7A76;</a></p>
<h2 id="mixin">Mixin</h2>
<p>&#x672C;&#x9879;&#x76EE;&#x6CA1;&#x6709;&#x8BBE;&#x7F6E;&#x81EA;&#x52A8;&#x6CE8;&#x5165; sass &#x7684; mixin &#x5230;&#x5168;&#x5C40;&#xFF0C;&#x6240;&#x4EE5;&#x9700;&#x8981;&#x5728;&#x4F7F;&#x7528;&#x7684;&#x5730;&#x65B9;&#x624B;&#x52A8;&#x5F15;&#x5165; mixin</p>
<pre class="language-"><code class="lang-scss">&lt;style rel=<span class="token string">&quot;stylesheet/scss&quot;</span> lang=<span class="token string">&quot;scss&quot;</span>&gt;
  <span class="token keyword">@import</span> <span class="token string">&quot;src/styles/mixin.scss&quot;</span><span class="token punctuation">;</span>
&lt;/style&gt;
</code></pre>
<p>&#x5982;&#x9700;&#x8981;&#x81EA;&#x52A8;&#x5C06; mixin &#x6CE8;&#x5165;&#x5230;&#x5168;&#x5C40; &#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<a href="https://github.com/shakacode/sass-resources-loader" target="_blank">sass-resources-loader</a></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="permission.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 权限验证">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"样式","level":"1.13","depth":1,"previous":{"title":"权限验证","level":"1.12","depth":1,"path":"src/permission.md","ref":"src/permission.md","articles":[]},"dir":"ltr"},"config":{"plugins":["expandable-chapters","-lunr","-search","search-pro","-highlight","prism","livereload"],"styles":{"website":"index.css"},"pluginsConfig":{"prism":{"css":["prismjs/themes/prism-tomorrow.css"]},"expandable-chapters":{},"search-pro":{},"livereload":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Gj","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"introduce","language":"zh-hans","gitbook":"3.2.3","description":"项目搭建、规范、使用示例介绍"},"file":{"path":"src/style.md","mtime":"2020-07-29T03:28:19.674Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-07-29T07:02:36.580Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

